home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga CD-ROM Collection
/
Amiga CD-ROM Collection - Auge 4000 and Cactus and Demo Util.iso
/
auge4000
/
46
/
lib
/
memory
/
malloc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-06-20
|
515b
|
38 lines
/*
* MALLOC.C
*
* (c)Copyright 1990, Matthew Dillon, All Rights Reserved
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <stdlib.h>
#include <errno.h>
extern long *__MemList;
extern void *AllocMem();
void *
malloc(bytes)
size_t bytes;
{
long *ptr;
if (bytes == 0)
return(NULL);
ptr = AllocMem(bytes + 8, MEMF_PUBLIC);
if (ptr) {
ptr[0] = (long *)__MemList;
__MemList = ptr;
ptr[1] = bytes + 8;
ptr += 2;
} else {
errno = ENOMEM;
}
return((void *)ptr);
}